﻿@using System.Web.Mvc.Html;
@using System.Web.WebPages.Html;
@using System.Web.Mvc;
@using DddCms.Models.UIComponent.Login;
@using DddCms.Models.UIComponent.Window;
@helper WindowFunc(Func<WindowViewModelBuilder, WindowViewModelBuilder> builder)
    {
    WindowViewModel viewmodel = builder(new WindowViewModelBuilder()).Build();
    string styleWidth = "width:" + viewmodel.Width + ";";
    if (viewmodel.MaxWidth != 0)
    {
        styleWidth = string.Format("max-width: {0}px;", viewmodel.MaxWidth);
    }
    
    string classForLeftPosition = string.Empty;
    switch(viewmodel.Position)
    {   
        case WindowPositionViewModel.Left:
            classForLeftPosition = "window-left";
            break;
        case WindowPositionViewModel.Right:
            classForLeftPosition = "window-right";
            break;
        case WindowPositionViewModel.Auto:
            classForLeftPosition = "window-auto";
            break;
    }
    <div class="window @viewmodel.Style @classForLeftPosition" max-width="@viewmodel.MaxWidth" style="@styleWidth">
        <div class="window-frame">
            @{string widthCenterTable = "";
             if(viewmodel.Width != "auto"){
                widthCenterTable = "width:100%";}}
                
            <table class="window-center-table" style="@widthCenterTable">
              <tr>
                    <td class="window-top-table-left">
                    </td>
                    <td class="window-top">
                    </td>
                    <td class="window-top-table-right">
                    </td>
                </tr>
                <tr>
                    <td class="window-center-table-left">
                    </td>
                    <td class="window-content">
                            @if(!string.IsNullOrWhiteSpace(viewmodel.Title))
                            {
                                <div class="window-content-title">@viewmodel.Title</div>
                            }
                            <div class="window-content-content">
                                @MvcHtmlString.Create(viewmodel.Content)
                            </div>
                    </td>
                    <td class="window-center-table-right">
                    </td>
                </tr>
                 <tr>
                    <td class="window-bottom-table-left">
                    </td>
                    <td class="window-bottom-table-bottom">
                    </td>
                    <td class="window-bottom-table-right">
                    </td>
                </tr>
            </table>
        </div>
    </div>
}

